var a,adr,auth,Delay=50,GM
var mp,dis=[1,1,1,1,1,1,1,1,1,1],b,i,j
var op={weekday:"short",year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}

var Rel_chg_a,IO_chg_a,Log_chg_a
var tb="<table class=ctrlb cellspacing=7 ondragstart=\"return false;\" ondrop=\"return false;\" border=0 style='font-size:8.5pt;color:#FFF;width:650px'><tr height=30>"
var tb1="<table id='one' cellspacing=7 border=0 ondragstart=\"return false;\" ondrop=\"return false;\" style='background:#bbb;color:#FFF;width:300px'>"

var bg_e= "background-color:#059105' class=bt"
var bg_a= "background-color:#5A4848' class=bt"
var bg_he="background-color:#089DF4' class=bt"
var bg_ha="background-color:#033451' class=bt"
var bg_ee="background-color:#837373;border:2px inset #ddd' class=bt1>"
var bg_ea="background-color:#6F9576;border:2px inset #ddd' class=bt1>"

var newP = document.createElement('p')
var ts,tt
var i_div=100
var cos_div=100
f_av =[0,0,0,0,0]
var fp=0, av, nn, wd=[0,0,0,0,0,0,0,0] ,wi=[0,0,0,0,0,0,0,0]
var tea_key

gI = function () {}
gI.id = function (div) { return document.getElementById(div);}
gN = function () {}
gN.n = function (div) { return document.getElementsByName(div)[0];}

function getOS(){
var userAgent = window.navigator.userAgent,
platform = window.navigator.platform,
macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'],
windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'],
iosPlatforms = ['iPhone', 'iPad', 'iPod'],
os = null;
if (macosPlatforms.indexOf(platform) !== -1) { os = 'Mac OS';}
else if (iosPlatforms.indexOf(platform) !== -1) { os = 'iOS';}
else if (windowsPlatforms.indexOf(platform) !== -1) { os = 'Windows';}
else if (/Android/.test(userAgent)) { os = 'Android';}
else if (!os && /Linux/.test(platform)) {os = 'Linux';}
return os;
}

function rdt(){
tg=new XMLHttpRequest()
tg.open("GET","txt/text_"+parent.Lang+'.txt',false)
tg.send("")
parent.ttd = tg.responseText.split("\r\n")
}

function lg(){
l=new XMLHttpRequest()
l.open("GET","txt/lang_"+parent.Lang+'.txt',false)
l.send("")
parent.lang_txt = l.responseText.split("\r\n")
}

function slg(){
if(parent.Lang==0){tt=",";ts="."}
if(parent.Lang==1){tt=".";ts=","}
var nodes= document.body.getElementsByTagName('*'),
L=nodes.length
while(L){
temp= nodes[--L].id || ''
if(temp.indexOf('lg_')== 0){
var nr=parseInt(temp.substring(3,6))
var tmp=gI.id(temp).innerHTML
gI.id(temp).innerHTML=parent.lang_txt[nr]+tmp}}
}

function slg_s(nr){
return parent.lang_txt[nr]
}

function dds(id){
gI.id(id).innerHTML="<span style='color:#990000'>"+slg_s(60)+"</span>"
gI.id("tb1").style.display="none"
gI.id("tb2").style.display="none"
gI.id("tb3").style.display="none"
}

function split_bin(i){
ret=new Array("","","","","","","","","","","","","","","","") 
var bin=parseInt(i).toString(2)
for(var j=0;j<bin.length;j++)
if(bin.substring(bin.length-1-j,bin.length-j)=="1") ret[j]="1"
return ret
}

function ok_fail_res(){
gI.id("ok").style.display="none"
gI.id("fail").style.display="none"
}

function sc(t,f) {
var f=document.forms[f];
for(var i=0;i<f.elements.length;i++){
if(f.elements[i].getAttribute('onchange')==null)
{f.elements[i].onchange=function(){gN.n(t).style.color='#CC0066';gN.n(t).style.fontWeight = "bold"}}}
}

function nf( x, len, sep, ts){
x = Math.round( x * Math.pow(10, len) ) / Math.pow(10, len);
str_no = x+"";
arr_int = str_no.split(".");
if(!arr_int[0]) arr_int[0] = "0";
if(!arr_int[1]) arr_int[1] = "";
if(arr_int[1].length < len){
nk = arr_int[1];
for(i=arr_int[1].length+1; i <= len; i++){  nk += "0";  }    arr_int[1] = nk;}
if(ts != "" && arr_int[0].length > 3){
b = arr_int[0];
arr_int[0] = "";
for(j = 3; j < b.length ; j+=3){
Extrakt = b.slice(b.length - j, b.length - j + 3);
arr_int[0] = ts + Extrakt +  arr_int[0] + "";}
str_first = b.substr(0, (b.length % 3 == 0)?3:(b.length % 3));
arr_int[0] = str_first + arr_int[0];}
return arr_int[0]+sep+arr_int[1];
}

function p_tm(t,typ){
if(typ==0)	// hh:mm
	tim=aLZ( t.getUTCHours(),2)+":"+aLZ(t.getUTCMinutes(),2)	
if(typ==1)	// hh:mm:ss
	tim=aLZ(t.getUTCHours(),2)+":"+aLZ(t.getUTCMinutes(),2)+":"+aLZ(t.getUTCSeconds(),2)	
if(typ==2)	// tt.mm.jjjj, hh:mm:ss
	tim=aLZ(t.getUTCDate(),2)+"."+aLZ(t.getUTCMonth()+1,2)+"."+t.getUTCFullYear()+", "+aLZ(t.getUTCHours(),2)+":"+aLZ(t.getUTCMinutes(),2)+":"+aLZ(t.getUTCSeconds(),2)	
if(typ==3)	// tt.mm.jjjj hh-mm-ss
	tim=aLZ(t.getUTCDate(),2)+"-"+aLZ(t.getUTCMonth()+1,2)+"-"+t.getUTCFullYear()+" "+aLZ(t.getUTCHours(),2)+"."+aLZ(t.getUTCMinutes(),2)+"."+aLZ(t.getUTCSeconds(),2)	
if(typ==4)	// WT tt.mm.jjjj, hh:mm:ss
	tim=parent.lang_txt[t.getUTCDay()+255]+" "+aLZ(t.getUTCDate(),2)+"."+aLZ(t.getUTCMonth()+1,2)+"."+t.getUTCFullYear()+", "+aLZ(t.getUTCHours(),2)+":"+aLZ(t.getUTCMinutes(),2)+":"+aLZ(t.getUTCSeconds(),2)	
if(typ==5)	// tt/mm/jjjj hh:mm:ss
	tim=aLZ(t.getUTCDate(),2)+"/"+aLZ(t.getUTCMonth()+1,2)+"/"+t.getUTCFullYear()+" "+aLZ(t.getUTCHours(),2)+":"+aLZ(t.getUTCMinutes(),2)+":"+aLZ(t.getUTCSeconds(),2)
if(typ==6)	// WT tt/mm/jjjj, hh:mm:ss english
	tim=parent.lang_txt[t.getUTCDay()+255]+" "+aLZ(t.getUTCDate(),2)+"/"+aLZ(t.getUTCMonth()+1,2)+"/"+t.getUTCFullYear()+", "+aLZ(t.getUTCHours(),2)+":"+aLZ(t.getUTCMinutes(),2)+":"+aLZ(t.getUTCSeconds(),2)	
if(typ==7)	// tt/mm/jj hh:mm:ss
	tim=aLZ(t.getUTCDate(),2)+"/"+aLZ(t.getUTCMonth()+1,2)+"/"+t.getUTCFullYear().toString().substr(-2)+" "+aLZ(t.getUTCHours(),2)+":"+aLZ(t.getUTCMinutes(),2)+":"+aLZ(t.getUTCSeconds(),2)
return tim
}

function aLZ(n,l){
var num = '' + n
while (num.length < l) num = '0' + num
return num
}

function repl(x){
var a=x.toString()
if(parent.Lang==0){
a=a.replace('.','')
a=a.replace(',','.')}
if(parent.Lang==1){
a=a.replace(',','')
a=a.replace('.','.')}
return a
}

function l_0(v){
var nz=16-v.length
if(nz) return Array(nz+1).join("0")+v 
return v
}

function B(b){
return Boolean(Number(b))
}

function init(){
xhttp=new XMLHttpRequest()
xhttp.open("GET","start.cfg",false)
xhttp.send("")
var p = xhttp.responseText.split(";") 

if(p[9]=='end'){
parent.Name=p[0]
newP.innerHTML=p[1]
parent.Name_Func=newP.innerHTML
parent.IP=p[2]
parent.Port=p[3]
var ll=p[4].split(",") 
parent.Login="<b>"+ll[0]+"</b> von "+ll[1]
var pp=p[5].split(",") 
parent.Typ=pp[0]
parent.UTyp=pp[1]
if(pp.length>2)parent.Typ_PRO_Power=pp[2] //8=PRO;''=Power
parent.Ver=p[6]
parent.alw=parseInt(p[7]).toString(2)}
parent.Lang=p[8]
gI.id("lg_13").href+='?'+parent.Lang
parent.build=" --- build: "+p[10]+" - "+p[11]
parent.No_Login = p[12]
}

function bit_test(num, bit){return ((num>>bit) % 2 != 0)}
function bit_set(num, bit){return num | 1<<bit}
function bit_clear(num, bit){return num & ~(1<<bit)}

function Pow_read(p){
parent.L1_4_V_factor = p[13]
parent.L1_4_A_factor = p[14]
parent.L1_4_P_factor = p[15]
parent.L1_4_F_factor = parseInt(p[16])
parent.R5_8_V_factor = p[17]
parent.R5_8_A_factor = p[18]
parent.R5_8_P_factor = p[19]
parent.R5_8_F_factor = parseInt(p[20])
parent.LN1_4_diff = p[21]
parent.LN5_8_diff = p[22]

for(var i=0;i<8;i++) parent.Sw_state[i] = p[23+i]
parent.Phase_R = p[31]
parent.Phase_L = p[32]
gI.id("bno").innerHTML = parent.Block_No = p[33]

xhttpm=new XMLHttpRequest()
xhttpm.open("GET","pm2.cfg",false)
xhttpm.overrideMimeType('text\/plain; charset=x-user-defined');
xhttpm.send("")
var pm = xhttpm.responseText
for(var i=0;i<152;i++){
var psv=i*4
pp0=(pm.charCodeAt(0+psv)&0xFF)
pp1=(pm.charCodeAt(1+psv)&0xFF)
pp2=(pm.charCodeAt(2+psv)&0xFF)
pp3=(pm.charCodeAt(3+psv)&0xFF)
parent.Pow_Reg[i]= pp0 + (pp1*256) + (pp2*65536) + (pp3*16777216)}

//Pow_calc
for(i=0;i<8;i++){
if(i<4){
parent.A_factor = parent.L1_4_A_factor
parent.V_factor = parent.L1_4_V_factor
parent.P_factor = parent.L1_4_P_factor
parent.F_factor = parent.L1_4_F_factor}
else{
parent.A_factor = parent.R5_8_A_factor
parent.V_factor = parent.R5_8_V_factor
parent.P_factor = parent.R5_8_P_factor
parent.F_factor = parent.R5_8_F_factor}

//A
mask = parseInt('7FFF', 16)
parent.Pow_A[i] = parseFloat((parseInt(parent.Pow_Reg[5+(19*i)])>>16 & mask)/parent.A_factor).toFixed(2)
if(parent.Sw_state[i]=='0') parent.Pow_A[i] = 0
gI.id("pow_a"+i).innerHTML = parseFloat(parent.Pow_A[i]).toFixed(1)
//V
parent.Pow_V[i] = parseFloat((parseInt(parent.Pow_Reg[5+(19*i)]) & mask)/parent.V_factor).toFixed(1)
//W
mask = parseInt('FFFF', 16)
parent.Pow_W[i] = parent.Pow_Reg[13+(19*i)]
if(bit_test(parent.Pow_W[i],16)){ // bit16=1
parent.Pow_W[i] &= mask
parent.Pow_W[i] = -((65535 - parent.Pow_W[i])/parent.P_factor).toFixed(1)}
else{
parent.Pow_W[i] &= mask
parent.Pow_W[i] = (parent.Pow_W[i]/parent.P_factor).toFixed(1)}
if(parent.Sw_state[i]=='0') parent.Pow_W[i] = 0
pw_tmp = Math.abs(parseFloat(parent.Pow_W[i]))
gI.id("pow_w"+i).innerHTML =  pw_tmp.toFixed(1)
//VA
parent.Pow_VA[i] = ((parseInt(parent.Pow_Reg[7+(19*i)]) & mask)/parent.P_factor).toFixed(1)
if(parseInt(parent.Pow_VA[i])>5000) parent.Pow_VA[i] = "OF"
if(parent.Sw_state[i]=='0' || pw_tmp<0.4) parent.Pow_VA[i] = 0
gI.id("pow_va"+i).innerHTML = parent.Pow_VA[i]
//VAR
parent.Pow_VAR[i] = ((parseInt(parent.Pow_Reg[8+(19*i)]) & mask)/parent.P_factor).toFixed(1)
if(parseInt(parent.Pow_VAR[i])>5000) parent.Pow_VAR[i] = "OF"
if(parent.Sw_state[i]=='0' || pw_tmp<0.4) parent.Pow_VAR[i] = 0
//PF
mask = parseInt('3FF', 16)
parent.Pow_PF[i] = parseInt(parent.Pow_Reg[9+(19*i)])
if(bit_test(parent.Pow_PF[i],10)){ // bit10=1
parent.Pow_PF[i] &= mask
parent.Pow_PF[i] = -((1023 - parent.Pow_PF[i])/512.000).toFixed(3)}
else{
parent.Pow_PF[i] &= mask
parent.Pow_PF[i] = (parent.Pow_PF[i]/512.000).toFixed(3)}
if(parent.Sw_state[i]=='0' || pw_tmp<0.4) parent.Pow_PF[i] = 0
//Hz
parent.Pow_Hz[i] = parseInt((parent.F_factor / parseInt(parent.Pow_Reg[10+(19*i)])).toFixed(1))
if(parent.Pow_Hz[i]>1000) parent.Pow_Hz[i] = -1

/*
parent.time_ar[i,parent.ar_no] 	=(p_tm(new Date(Date.now()),5))
parent.V_ar[i,parent.ar_no]		=(parent.Pow_V[i])
parent.I_ar[i,parent.ar_no]		=(parent.Pow_A[i]) 
parent.W_ar[i,parent.ar_no]		=(parent.Pow_W[i]) 
parent.VA_ar[i,parent.ar_no]	=(parent.Pow_VA[i]) 
parent.VAR_ar[i,parent.ar_no]	=(parent.Pow_VAR[i]) 
parent.PF_ar[i,parent.ar_no]	=(parent.Pow_PF[i]) 
parent.Hz_ar[i,parent.ar_no]	=(parent.Pow_Hz[i]) 
parent.ar_no[i]++*/}

if(parent.Typ_PRO_Power=='8'){
gI.id("V_1_8").innerHTML = parent.Pow_V[0]+ " V"
gI.id("H_1_8").innerHTML = Math.round(parent.Pow_Hz[0])+ " Hz"}
else{
gI.id("V_1_4").innerHTML = parent.Pow_V[0]+ " V"
gI.id("V_5_8").innerHTML = parent.Pow_V[4]+ " V"
gI.id("H_1_4").innerHTML = Math.round(parent.Pow_Hz[0])+ " Hz"
gI.id("H_5_8").innerHTML = Math.round(parent.Pow_Hz[4])+ " Hz"}
}

function tm(){
xhttp=new XMLHttpRequest()
xhttp.open("GET","daten.cfg",false)
//xhttp.overrideMimeType('text\/plain; charset=x-user-defined');
xhttp.send("")
var p = xhttp.responseText.split(";") 
if(p[0]=='logout'){
document.head.innerHTML="<!doctype html><meta http-equiv='content-type' content='text/html; charset=utf-8'><meta name='viewport' content='width=device-width'><style>body{font-family:Verdana;padding:150px;width:250px;}</style>"
document.title='Net-PwrCtrl Logout'
document.body.innerHTML = "<div style='background-color:#CCC;padding:30px'>NET-PwrCtrl - Logout<br><br>Close the Browser</div></html>"
return}
if(p[11]=='end'){
parent.a_time=p[0]*1000
parent.Rel_chg=p[1]
parent.IO_chg=p[2]
parent.Log_chg=p[3]
parent.ClockStat=p[4]
parent.BootTime=parseInt(p[5])+parseInt(p[6])*65536
parent.Temp=nf(parseFloat(p[7]),1,tt,ts)
parent.Log_o=p[8]
parent.Log_t=p[9]
parent.timer_no=p[10]
if(p[12]=='P') Pow_read(p)

if(p[18]=='s') os=6; else os=0
parent.S_ON=p[12+os]
if(p[12+os]=='s'){
parent.Sens_Beg=p[13+os]
if(p[14+os]==parseFloat(128.86)) p[14+os]='---'; else p[14+os]=nf(parseFloat(p[14+os]),2,tt,ts)+' °C'
if(p[15+os]==parseFloat(113.0))  p[15+os]='---'; else p[15+os]=nf(parseFloat(p[15+os]),1,tt,ts)+' %'
parent.S_Temp=p[14+os]
parent.S_Hum=p[15+os]
parent.S_Lux=p[16+os]+' lx'
parent.First_Sens=p[17+os]
parent.Temp_sw=p[18+os]
parent.SHA256_Test=p[19+os]}}
}

function s(t,adr,auth){
xhttps=new XMLHttpRequest()
xhttps.open("POST",adr+"ctrl.htm"+auth,false)
xhttps.setRequestHeader("Content-type","text/plain")
if(t=='h') xhttps.send('h=0'); else xhttps.send(t)
}

function rel_r(adr,auth){
xhttpe=new XMLHttpRequest()
xhttpe.open("GET",adr+"strg.cfg"+auth,false)
xhttpe.send("")
a = xhttpe.responseText.split(";")
}

function io_r(adr,auth){
try{xhttpi=new XMLHttpRequest()
xhttpi.open("GET",adr+"ioa.cfg"+auth,false)
xhttpi.send("")
a = xhttpi.responseText.split(";")} catch(e){return false}
}

function sw_F(i,b){
b.style.boxShadow="2px 2px 2px #fff";	
b.style.textShadow="2px 2px 2px rgba(0,0,0,0.5)"
Rel_chg_a++
s('F'+i+'=S','','')
del_rel()
}

function sw_f(i){
if(wd[i]>0){wd[i]=0
Rel_chg_a++
s('f'+i+'=S','','')
del_rel()}	
}

function sw_g(i){
if(wd[i]==0){wd[i]++
Rel_chg_a++
s('g'+i+'=S','','')
del_rel()}	
}

function sw_E(i,b){
b.style.boxShadow="2px 2px 2px #fff";	
b.style.textShadow="2px 2px 2px rgba(0,0,0,0.5)"
IO_chg_a++
s('E'+i+'=S','','')
del_io()
}

function sw_e(i){
if(wi[i]>0){wi[i]=0
IO_chg_a++
s('e'+i+'=S','','')
del_io()}	
}

function sw_d(i){
if(wi[i]==0){wi[i]++
IO_chg_a++
s('d'+i+'=S','','')
del_io()}
}

function sw(i){
/*
if(i==0) gI.id('lg_0').innerHTML+="onmousedown "	
if(i==1) gI.id('lg_0').innerHTML+="onmouseup "	
if(i==2) gI.id('lg_0').innerHTML+="ontouchstart "	
if(i==3) gI.id('lg_0').innerHTML+="ontouchcancel "	
if(i==4) gI.id('lg_0').innerHTML+="ontouchend "	
if(i==5) gI.id('lg_0').innerHTML+="ontouchleave "	
if(i==6) gI.id('lg_0').innerHTML+="onmouseover "	
*/
}

function r_read(adr,auth){
var b,i
rel_r(adr,auth)
var t='', sf=0, N
if(parent.OS=="Android" || parent.OS=="iOS") t="2>"; else t=">" 
if(parent.ttd===undefined)rdt()
if(a[40]=='end'){
b=tb	
for(i=0;i<8;i++){N=a[i*5+4];parent.d_alw[i]=a[i*5+2];if(parent.d_alw[i]==0&&sf==0){parent.tab_nr=i;sf=1}

if(a[i*5+2]==1){b+="<td id=rbt"+i+" title='"+parent.lang_txt[25]+"' style='";if(a[i*5+1]==1)b+=bg_ea; else b+=bg_ee;} //gesperrt
else {
var Nr=a[i*5+3];Nr++
b+="<td id=rbt"+i+" title='"+parent.ttd[Nr]
if(a[i*5+2]==1) b+="'"
else{if(a[i+41]==1){
if(parent.OS=="iOS")b+="' ontouchstart=\"sw(2);sw_g("+i+")\" onmouseup=\"sw(1);sw_f("+i+")\""
else if(parent.OS=="Android") b+="' ontouchstart=\"sw(2);sw_g("+i+")\" ontouchend=\"sw(4);sw_f("+i+")\""
else b+="' onmousedown=\"sw(0);sw_g("+i+")\" onmouseup=\"sw(1);sw_f("+i+")\""}
else b+="' onmousedown=\"sw(0);sw_F("+i+",this);parent.soc_no="+i+"\""}
b+=" style='";if(N.match('B'))b+='box-shadow: 0 0 0 2px #fff inset;';
if(a[i+41]==1){if(a[i*5+1]==1) b+=bg_he+t; else b+=bg_ha+t} else {if(a[i*5+1]==1) b+=bg_e+t; else b+=bg_a+t}
 }
b+="<div class=bbt>"+a[i*5]+"</div>"
if(a[i+49]!='0'){b+="<div class=bt_div title=\""
if(N.match('IO'))b+=parent.lang_txt[33]+"\n"
if(N.match('W'))b+=parent.lang_txt[28]+"\n"
if(N.match('K'))b+=parent.lang_txt[26]+"\n"
if(N.match('B'))b+=parent.lang_txt[27]+"\n"
if(N.match('P'))b+=parent.lang_txt[34]+"\n"
if(N.match('S'))b+=parent.lang_txt[18]
b+="\" style=\"font-size:27px;"
if(N.match('W')) b+="color:#1de08f"; else b+="color:#bbb" 
b+="\">&#"+(a[i+49])+";</div>"}
b+="<div class=bt_div>"+N+"</div>"
if(i==3)b+="<tr height=30>"}
b+="</table>" 
document.getElementById('rel_z').innerHTML=b}
}

function io_read(adr,auth){
var b,i;a=""
io_r(adr,auth)
var t=''
if(parent.OS=="Android" || parent.OS=="iOS") t="2>"; else t=">" 
if(a.length==1) return
try{document.getElementById('io_div').style.display="inline"}catch(e){}
if(a[33]=='end'){
b=tb	
for(i=0;i<8;i++){
var s=B(a[i*4+2]),ea=B(a[i*4+3]),inv=B(a[i*4+4])
b+="<td title='"
if(!ea){b+=parent.lang_txt[29]
if(inv){b+="\n"+parent.lang_txt[30];s=!s}
if(a[i+34]==1){if(parent.OS=="iOS")b+="' ontouchstart=\"sw(2);sw_d("+i+")\" onmouseup=\"sw(1);sw_e("+i+")\""
else if(parent.OS=="Android") b+="' ontouchstart=\"sw(2);sw_d("+i+")\" ontouchend=\"sw(4);sw_e("+i+")\""
else b+="' onmousedown=\"sw_d("+i+")\" onmouseup=\"sw_e("+i+")\""}
else b+="' onmousedown=\"sw_E("+i+",this)\""
b+=" style='";if(a[i+50]=='1')b+='box-shadow: 0 0 0 2px #fff inset;';
if(a[i+34]==1){if(s) b+=bg_he+t; else b+=bg_ha+t} else {if(s) b+=bg_e+t; else b+=bg_a+t}}
else{b+=parent.lang_txt[31]
if(inv){b+="\n"+parent.lang_txt[30];s=!s}
b+="' style='"
if(s) b+=bg_ee; else b+=bg_ea}
b+="<div class=bbt>"+a[i*4+1]+"</div>" 
if(a[i+42]!='0')b+="<div class=bt_div style=\"font-size:27px\">&#"+(a[i+42])+";</div>"
if(i==3)b+="<tr height=30>"}
b+="</table>" 
document.getElementById('io_z').innerHTML=b}
}

function del_rel(){window.setTimeout("r_read('','')",Delay)}
function del_io(){window.setTimeout("io_read('','')",Delay)}
function ref(){rel_ch();io_ch()}
function rel_ch(){if(parent.Rel_chg!=Rel_chg_a){Rel_chg_a=parent.Rel_chg;parent.rel_changed=1;r_read('','')}}
function io_ch(){if(parent.IO_chg!=IO_chg_a){IO_chg_a=parent.IO_chg;io_read('','')}}

